package com.wyl.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wyl.auth.entity.SysUser;
import com.wyl.auth.entity.UserLoginLog;
import com.wyl.auth.mapper.UserLoginLogMapper;
import com.wyl.auth.req.UserLoginLogReq;
import com.wyl.auth.service.SysUserService;
import com.wyl.auth.service.UserLoginLogService;
import com.wyl.auth.util.BeanAwareUtil;
import com.wyl.auth.vo.UserLoginLogVo;
import com.wyl.common.CommonPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @Description 用户登录日志表
* @Author WuYiLong
* @Date 2025-04-13
*/
@Service
public class UserLoginLogServiceImpl extends ServiceImpl<UserLoginLogMapper, UserLoginLog> implements UserLoginLogService {

    @Autowired
    private SysUserService sysUserService;

    @Override
    public CommonPage<UserLoginLogVo> page(UserLoginLogReq req) {
        Page<UserLoginLog> page = new Page<>(req.getCurrentPage(), req.getPageSize());
        List<UserLoginLogVo> userLoginLogVos = baseMapper.selectPage(page, req);
        CommonPage<UserLoginLogVo> commonPage = new CommonPage<>(req.getCurrentPage(), req.getPageSize());
        commonPage.setList(userLoginLogVos);
        commonPage.setTotal((int)page.getTotal());
        return commonPage;
    }

    @Override
    public void deleteByIds(List<Long> ids) {
        removeByIds(ids);
    }
}
